import request from '@/utils/request'

// 查询帖子列表
export function listPost(query) {
  return request({
    url: '/system/post/list',
    method: 'get',
    params: query
  })
}

// 查询帖子详细
export function getPost(postId) {
  return request({
    url: '/system/post/' + postId,
    method: 'get'
  })
}

// 删除帖子
export function delPost(postId) {
  return request({
    url: '/system/post/' + postId,
    method: 'delete'
  })
}

// 导出帖子
export function exportPost(query) {
  return request({
    url: '/system/post/export',
    method: 'get',
    params: query
  })
}

// 修改帖子状态
export function changePostStatus(postId, status) {
  const data = {
    postId,
    status
  }
  return request({
    url: '/system/post/changeStatus',
    method: 'put',
    data: data
  })
}

// 设置/取消精华
export function toggleFeatured(postId, isFeatured) {
  const data = {
    postId,
    isFeatured
  }
  return request({
    url: '/system/post/toggleFeatured',
    method: 'put',
    data: data
  })
}

// 设置/取消置顶
export function toggleSticky(postId, isSticky) {
  const data = {
    postId,
    isSticky
  }
  return request({
    url: '/system/post/toggleSticky',
    method: 'put',
    data: data
  })
}

// 查询帖子评论列表
export function listPostComments(postId, query) {
  return request({
    url: '/system/post/' + postId + '/comments',
    method: 'get',
    params: query
  })
}

// 删除帖子评论
export function delPostComment(commentId) {
  return request({
    url: '/system/post/comment/' + commentId,
    method: 'delete'
  })
}